package com.bush.mall.coupon.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.coupon.entity.CouponSpuCategoryRelationEntity;
import com.bush.mall.coupon.service.CouponSpuCategoryRelationService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 优惠券分类关联
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("coupon/category/relation")
@Api(tags = "优惠券分类关联管理" )
public class CouponSpuCategoryRelationController {

    @Resource(name= CouponSpuCategoryRelationService.BEAN_ID)
    private CouponSpuCategoryRelationService couponSpuCategoryRelationService;

    /**
     * 分页查询优惠券分类关联列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询优惠券分类关联列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return couponSpuCategoryRelationService.queryForPage(current,size);
    }

    /**
     * 保存优惠券分类关联表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存优惠券分类关联表单")
    @PostMapping
    public Result saveCouponSpuCategoryRelation(@RequestBody CouponSpuCategoryRelationEntity couponSpuCategoryRelation){
        return couponSpuCategoryRelationService.saveCouponSpuCategoryRelation(couponSpuCategoryRelation);
    }

    /**
     * 修改优惠券分类关联表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改优惠券分类关联表单")
    @PutMapping
    public Result updateCouponSpuCategoryRelation(@RequestBody CouponSpuCategoryRelationEntity couponSpuCategoryRelation){
        return couponSpuCategoryRelationService.updateCouponSpuCategoryRelation(couponSpuCategoryRelation);
    }

    /**
     * 通过指定id删除优惠券分类关联
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除优惠券分类关联")
    @DeleteMapping
    public Result deleteCouponSpuCategoryRelation(Long id){
        return couponSpuCategoryRelationService.deleteCouponSpuCategoryRelation(id);
    }

}
